package com.example.demo.thread;

import com.example.demo.enums.ThreadPoolEnum;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @program: demo
 * @description:
 * @author: yby
 * @create: 2020-06-30 17:05
 **/
public class AsyncTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String ss = "我是线程1";
        Future<String> submit = task(ss);
        String str = submit.get();
        System.out.println("submit=" + str);
    }

    private static String query(String str) {
        return str;
    }

    static Future<String> task(String strr) {
        Future<String> submit = ThreadPoolEnum.INSTANCE.submit(new Callable<String>() {
            @Override
            public String call() throws Exception {
                String str = query(strr);
                return str;
            }
        });
        return null;
    }


}
